home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / kerberos / pc / krb_libw.lha / Lib / WINKRB / NETWRITE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-23  |  979 b   |  50 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/netwrite.c,v $
  3.  * $Author: jtkohl $
  4.  *
  5.  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
  6.  *
  7.  * For copying and distribution information, please see the file
  8.  * <mit-copyright.h>.
  9.  */
  10.  
  11. #include <mit_copy.h>
  12. #include <conf.h>
  13. #ifdef WINDOWS
  14. #include <windows.h>
  15. #include <sys/socket.h>
  16. #endif
  17.  
  18. /*
  19.  * krb_net_write() writes "len" bytes from "buf" to the file
  20.  * descriptor "fd".  It returns the number of bytes written or
  21.  * a write() error.  (The calling interface is identical to
  22.  * write(2).)
  23.  *
  24.  * XXX must not use non-blocking I/O
  25.  */
  26.  
  27. int
  28. krb_net_write(fd, buf, len)
  29. int fd;
  30. register char *buf;
  31. int len;
  32. {
  33.     int cc;
  34.     register int wrlen = len;
  35.     do {
  36. #ifdef IBMPC
  37.     cc = sowrite(fd, buf, wrlen);
  38. #else
  39.     cc = write(fd, buf, wrlen);
  40. #endif
  41.     if (cc < 0)
  42.         return(cc);
  43.     else {
  44.         buf += cc;
  45.         wrlen -= cc;
  46.     }
  47.     } while (wrlen > 0);
  48.     return(len);
  49. }
  50.